From f2a491843da3d9918eabf0efa5377782c1a0aa68 Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Wed, 11 Jan 2006 11:34:05 +0100 Subject: [PATCH] Fix 32-bit shadow mode to handle extended perdomain mapping area now that mapcache is per domain. Signed-off-by: Keir Fraser --- xen/arch/x86/shadow.c | 9 ++++++--- xen/arch/x86/shadow32.c | 17 +++++++++++------ xen/arch/x86/shadow_public.c | 8 +++++--- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/xen/arch/x86/shadow.c b/xen/arch/x86/shadow.c index e6c59eb58d..b2fd143452 100644 --- a/xen/arch/x86/shadow.c +++ b/xen/arch/x86/shadow.c @@ -469,6 +469,7 @@ static unsigned long shadow_l2_table( { unsigned long smfn; l2_pgentry_t *spl2e; + int i; SH_VVLOG("shadow_l2_table(gpfn=%lx, gmfn=%lx)", gpfn, gmfn); @@ -503,9 +504,11 @@ static unsigned long shadow_l2_table( spl2e[l2_table_offset(SH_LINEAR_PT_VIRT_START)] = l2e_from_pfn(smfn, __PAGE_HYPERVISOR); - spl2e[l2_table_offset(PERDOMAIN_VIRT_START)] = - l2e_from_paddr(__pa(page_get_owner(pfn_to_page(gmfn))->arch.mm_perdomain_pt), - __PAGE_HYPERVISOR); + for ( i = 0; i < PDPT_L2_ENTRIES; i++ ) + spl2e[l2_table_offset(PERDOMAIN_VIRT_START) + i] = + l2e_from_page(virt_to_page(page_get_owner(pfn_to_page(gmfn))-> + arch.mm_perdomain_pt) + i, + __PAGE_HYPERVISOR); if ( shadow_mode_translate(d) ) // NB: not external { diff --git a/xen/arch/x86/shadow32.c b/xen/arch/x86/shadow32.c index b70db99eb4..eb09ea92c5 100644 --- a/xen/arch/x86/shadow32.c +++ b/xen/arch/x86/shadow32.c @@ -726,6 +726,7 @@ static void alloc_monitor_pagetable(struct vcpu *v) l2_pgentry_t *mpl2e; struct pfn_info *mmfn_info; struct domain *d = v->domain; + int i; ASSERT(pagetable_get_paddr(v->arch.monitor_table) == 0); @@ -740,9 +741,10 @@ static void alloc_monitor_pagetable(struct vcpu *v) &idle_pg_table[DOMAIN_ENTRIES_PER_L2_PAGETABLE], HYPERVISOR_ENTRIES_PER_L2_PAGETABLE * sizeof(l2_pgentry_t)); - mpl2e[l2_table_offset(PERDOMAIN_VIRT_START)] = - l2e_from_paddr(__pa(d->arch.mm_perdomain_pt), - __PAGE_HYPERVISOR); + for ( i = 0; i < PDPT_L2_ENTRIES; i++ ) + mpl2e[l2_table_offset(PERDOMAIN_VIRT_START) + i] = + l2e_from_page(virt_to_page(d->arch.mm_perdomain_pt) + i, + __PAGE_HYPERVISOR); // map the phys_to_machine map into the Read-Only MPT space for this domain mpl2e[l2_table_offset(RO_MPT_VIRT_START)] = @@ -1508,6 +1510,7 @@ static unsigned long shadow_l2_table( { unsigned long smfn; l2_pgentry_t *spl2e; + int i; SH_VVLOG("shadow_l2_table(gpfn=%lx, gmfn=%lx)", gpfn, gmfn); @@ -1542,9 +1545,11 @@ static unsigned long shadow_l2_table( spl2e[l2_table_offset(SH_LINEAR_PT_VIRT_START)] = l2e_from_pfn(smfn, __PAGE_HYPERVISOR); - spl2e[l2_table_offset(PERDOMAIN_VIRT_START)] = - l2e_from_paddr(__pa(page_get_owner(pfn_to_page(gmfn))->arch.mm_perdomain_pt), - __PAGE_HYPERVISOR); + for ( i = 0; i < PDPT_L2_ENTRIES; i++ ) + spl2e[l2_table_offset(PERDOMAIN_VIRT_START) + i] = + l2e_from_page(virt_to_page(page_get_owner(pfn_to_page(gmfn))-> + arch.mm_perdomain_pt) + i, + __PAGE_HYPERVISOR); if ( shadow_mode_translate(d) ) // NB: not external { diff --git a/xen/arch/x86/shadow_public.c b/xen/arch/x86/shadow_public.c index 55d0196e47..bb376bb737 100644 --- a/xen/arch/x86/shadow_public.c +++ b/xen/arch/x86/shadow_public.c @@ -328,6 +328,7 @@ static void alloc_monitor_pagetable(struct vcpu *v) l2_pgentry_t *mpl2e; struct pfn_info *mmfn_info; struct domain *d = v->domain; + int i; ASSERT(pagetable_get_paddr(v->arch.monitor_table) == 0); @@ -342,9 +343,10 @@ static void alloc_monitor_pagetable(struct vcpu *v) &idle_pg_table[DOMAIN_ENTRIES_PER_L2_PAGETABLE], HYPERVISOR_ENTRIES_PER_L2_PAGETABLE * sizeof(l2_pgentry_t)); - mpl2e[l2_table_offset(PERDOMAIN_VIRT_START)] = - l2e_from_paddr(__pa(d->arch.mm_perdomain_pt), - __PAGE_HYPERVISOR); + for ( i = 0; i < PDPT_L2_ENTRIES; i++ ) + mpl2e[l2_table_offset(PERDOMAIN_VIRT_START) + i] = + l2e_from_page(virt_to_page(d->arch.mm_perdomain_pt) + i, + __PAGE_HYPERVISOR); // map the phys_to_machine map into the Read-Only MPT space for this domain mpl2e[l2_table_offset(RO_MPT_VIRT_START)] = -- 2.30.2